/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MenuUtamaSistem;

import Koneksi.koneksi;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.swing.JInternalFrame;

/**
 *
 * @author Ignacio
 */
public class MenuUtamaController {
    
    private JInternalFrame inter;
    
    private static Connection connect;
    private static MenuUtamaController menucontrol;
     /**
     * @return the main
     */
    
    public MenuUtamaController(){
        
    }
    public MenuUtamaController(Connection konek) {
        this.connect = konek;
    }

    public static MenuUtamaController getKoneksiKontrol() throws SQLException, FileNotFoundException, IOException {
        if (menucontrol == null) {
            menucontrol = new MenuUtamaController(koneksi.getDBConnection());
        }
        return menucontrol;

    }
    

   
    /**
     * @return the inter
     */
    public JInternalFrame getInter() {
        return inter;
    }

    /**
     * @param inter the inter to set
     */
    public void setInter(JInternalFrame inter) {
        this.inter = inter;
    }
    
    public Login cekUser(String user) throws SQLException{
        Login set=new Login();
        CallableStatement state=null;
        String sql="{CALL cekuser(?,?,?)}";
        state=connect.prepareCall(sql);
        state.setString(1, user);
        state.registerOutParameter(2, java.sql.Types.VARCHAR);
        state.registerOutParameter(3, java.sql.Types.VARCHAR);
        state.execute();
        set.setUser(user) ;
        set.setPass(state.getString(2));
        set.setJabatan(state.getString(3));
        state.execute();
        state.close();
        return set;
    }
    
}
